﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace ExcelAutomator.Configuration
{
	[Serializable]
	[XmlRoot("settings", Namespace = Constants.Namespace)]
	public class SettingsConfiguration
	{
		public SettingsConfiguration()
		{
			SearchPattern = new List<string>(new[]{"*.xls", "*.xlsm", "*.xlsx"});
		}


		[XmlAttribute("target")]
		public string Target { get; set; }

		private string m_Input;

		[XmlAttribute("input")]
		public string Input
		{
			get
			{
				return Path.IsPathRooted(m_Input) ? m_Input : Path.Combine(Environment.CurrentDirectory, m_Input);
			} 
			set { m_Input = value; }
		}

		[XmlElement("filenamePattern")]
		public string FilenamePattern { get; set; }

		[XmlIgnore]
		public IList<string> SearchPattern { get; set; }

		[XmlIgnore]
		public bool ScanSubFolders { get; set; }

		[XmlAttribute("outputFolder")]
		public string OutputFolder
		{
			get;
			set;
		}

		[XmlIgnore]
		public bool IsOutDirectoryDefined
		{
			get
			{
				return !string.IsNullOrEmpty(OutputFolder);
			}
		}

	}
}
